package com.java.controller;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.java.service.OssService;

/**
 * OssController
 * <p>
 * </p>
 *
 * @author Vigor Yuan
 */
@RestController
@RequestMapping(value = "/oss")
public class OssController {

    Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    OssService ossService;

    @RequestMapping(value = "/getPolicy", method = RequestMethod.POST)
    public Map<String, String> getPolicy(@RequestParam(value = "Jdata") String Jdata) {
        JSONObject jsonObject = JSON.parseObject(Jdata);
        JSONObject data = jsonObject.getJSONObject("data");
        return ossService.getPolicy(data.getString("filePath"));
    }
}
